﻿@using Main.Core.Entities.SubEntities
@using WB.Core.BoundedContexts.Designer.Resources
@using WB.Core.BoundedContexts.Designer.Views.Questionnaire.Pdf
@using WB.UI.Designer.Utils
@model Main.Core.Entities.SubEntities.IGroup
@{
    PdfQuestionnaireModel questionnaire = ViewBag.Questionnaire;
    var roster = Model!;
}
<div class="roster">
    <div class="roster_container">
        <div class="breacrumbs">@questionnaire.GetBreadcrumbsForGroup(roster.PublicKey)</div>
        <div class="roster-title" id="@questionnaire.GetItemRef(roster.PublicKey)"><span>@PdfStrings.Roster</span>@questionnaire.GetGroupTitle(roster)</div>
        <div class="generated_by">
            <div>
                <div style="float: left; overflow: hidden;"> 
                    @if (roster.RosterSizeSource == RosterSizeSourceType.FixedTitles)
                    {
                        <span>@PdfStrings.Roster_GeneretedByFixedList</span>
                    }
                    else
                    {
                       <span>@Pdf.Format(PdfStrings.Roster_GeneretedByQuestion, questionnaire.GetStringifiedTypeOfRosterSizeQuestion(roster.RosterSizeQuestionId), string.Format(@"<a href=""#{0}"">{1}</a>", roster.RosterSizeQuestionId.HasValue ? questionnaire.GetItemRef(roster.RosterSizeQuestionId.Value) : "", questionnaire.GetRosterSourceQuestionVariable(roster.PublicKey)))</span>
                    }
                    </div>
                <div class="variable_name">@(roster.VariableName)</div>
            </div>

            @if (roster.RosterSizeSource == RosterSizeSourceType.FixedTitles)
            {
                <div style="clear: both; padding-top: 5px;">
                    <ul>
                        @foreach (var rosterTitle in roster.FixedRosterTitles)
                        {
                            <li><span>@questionnaire.GetFormattedFixedRosterValue(roster, rosterTitle.Value)</span>@rosterTitle.Title</li>
                        }
                    </ul>
                </div>
            }
            
        </div>
            
        
        @if (questionnaire.GroupHasEnablementCondition(roster))
        {
            <div class="common-info">
                <div class="condition">
                    <span>E</span>@questionnaire.GetExpressionExcerpt(roster.ConditionExpression)
                    @if (questionnaire.ExpressionIsTooLong(roster.ConditionExpression))
                    {
                        <div class="more">
                            <a href="#@questionnaire.GetConditionRef(roster.PublicKey)">
                                @Pdf.Format(PdfStrings.AppendixLink, roster.ConditionExpression.Length - questionnaire.Settings.ExpressionExcerptLength, questionnaire.GetEntityIndexInAppendix(roster.PublicKey, "E"))
                            </a>
                        </div>
                    }
                </div>
            </div>
        }
    </div>

</div>
@await Html.PartialAsync("_RenderChildren", roster.PublicKey)
<div class="group_footer"></div>
